// Created by zyq on 2025/3/31.
#include "iostream"

using namespace std;


class AbstractClass {
public:
    //纯虚函数 = 0
    virtual void PrimitiveOperation1() = 0;

    virtual void PrimitiveOperation2() = 0;


    void TemplateMethod() {
        cout << "TemplateMethod" << endl;
        PrimitiveOperation1();
        PrimitiveOperation2();
    }
};

class ConcreteClassA : public AbstractClass {
    void PrimitiveOperation1() override {
        cout << "PrimitiveOperation1" << endl;
    }

    void PrimitiveOperation2() override {
        cout << "PrimitiveOperation2" << endl;
    }
};

class ConcreteClassB : public AbstractClass {
    void PrimitiveOperation1() override {
        cout << "PrimitiveOperation1" << endl;
    }

    void PrimitiveOperation2() override {
        cout << "PrimitiveOperation2" << endl;
    }
};

int main() {
    AbstractClass *abstractClass;
    abstractClass = new ConcreteClassA();
    abstractClass->TemplateMethod();

    abstractClass = new ConcreteClassB();
    abstractClass->TemplateMethod();

    delete abstractClass;

    return 0;
}


